//
//  discountCollectionViewCell.m
//  Journey
//
//  Created by dllo on 16/5/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "discountCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation discountCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatediscount];
    }
    return self;
}

-(void)creatediscount{
    self.photo = [[UIImageView alloc] init];
  //  self.photo.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.photo];
    self.cnnameLabel = [[UILabel alloc] init];
 //  self.cnnameLabel.backgroundColor = [UIColor cyanColor];
    self.cnnameLabel.textColor = [UIColor whiteColor];
    self.cnnameLabel.textAlignment = NSTextAlignmentCenter;
    self.cnnameLabel.numberOfLines = 2;
    [self.contentView addSubview:self.cnnameLabel];
    self.ennameLabel = [[UILabel alloc] init];
  //  self.ennameLabel.backgroundColor = [UIColor cyanColor];
    self.ennameLabel.textColor = [UIColor whiteColor];
    self.ennameLabel.textAlignment = NSTextAlignmentNatural;
    [self.contentView addSubview:self.ennameLabel];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.photo.frame = self.contentView.bounds;
    self.cnnameLabel.frame = CGRectMake(self.contentView.frame.size.width / 4, self.contentView.frame.size.height / 4, self.contentView.frame.size.width / 2, self.contentView.frame.size.height / 2);
 //   self.ennameLabel.frame = CGRectMake(self.cnnameLabel.frame.origin.x, self.cnnameLabel.frame.origin.y + self.cnnameLabel.frame.size.height, self.cnnameLabel.frame.size.width, self.cnnameLabel.frame.size.height);
}

-(void)setDetail:(detailsModel *)detail{
    _detail = detail;

   [self.photo sd_setImageWithURL:[NSURL URLWithString:_detail.photo] placeholderImage:[UIImage imageNamed:@"image2"]];
    
    self.cnnameLabel.text = [NSString stringWithFormat:@"%@\n%@",detail.cnname,detail.enname];
    
    
   // self.ennameLabel.text = _detail.enname;
}

@end
